(function() {
    var itemColor = {
        baseH:354,
        baseS:100,
        baseL:42.5,
        stepH:6,
        stepS:-1,
        stepL:3,
        maxSpan:7,
        spanH: 49,
        spanS: -7,
        spanL: 21,

        calItemColor: function(index, count) {
            var sH = this.stepH, sS = this.stepS, sL = this.stepL;
            if (count > this.maxSpan) {  
                sH = this.spanH / count;
                sS = this.spanS / count;
                sL = this.spanL / count;
            }
            return 'hsl(' + (this.baseH + index * sH) + ','
                          + (this.baseS + index * sS) + '%,'
                          //+ (index ? (this.baseS - 10) : this.baseS) + '%,'
                          + (this.baseL + index * sL) + '%)';
        }
    };

    var collectColor = {
        baseH:212,
        baseS:93,
        baseL:53,
        maxSpan:5,
        stepH:-2.5,
        stepS:1,
        stepL:2.5,
        spanH: -12.5,
        spanS: 5,
        spanL: 12.5,

        calItemColor: function(index, count) {
            var sH = this.stepH, sS = this.stepS, sL = this.stepL;
            if (count > this.maxSpan) {  
                sH = this.spanH / count;
                sS = this.spanS / count;
                sL = this.spanL / count;
            }
            return 'hsl(' + (this.baseH + index * sH) + ','
                          + Math.min(100, (this.baseS + index * sS)) + '%,'
                          + Math.min(100, (this.baseL + index * sL)) + '%)';
        }
    };

    module.exports = {
        itemColor: itemColor,
        collectColor: collectColor
    };
})(); 